#include <bits/stdc++.h>
using namespace std;

#define NAME "detect"
const int N = 1e5+5, mod = 998244353;

using LL = long long;
//#define int long long

int a[N], v[N], s[N], p[N], n,m;
int l[N], r[N], maxv, nn;
pair<int, int> pa[N];

int bs(int i) {
    int l = lower_bound(p, p+m, s[i])-p, r = m-1;
    while (l < r) {
        int mid = (l+r-1) >> 1;
        int S = p[mid]-s[i];
        int sp = v[i] * v[i] + 2 * a[i] * S;
        if (sp > maxv * maxv) {
            r = mid;
        } else {
            l = mid+1;
        }
        
    }
    int S = p[r]-s[i];
    int sp = v[i] * v[i] + 2 * a[i] * S;
    if (sp <= maxv*maxv) return -1;
    return r;
}

int bs2(int i) {
    int l = lower_bound(p, p+m, s[i])-p, r = m-1;
    while (l < r) {
        int mid = (l+r+1) >> 1;
        int S = p[mid]-s[i];
        int sp = v[i] * v[i] + 2 * a[i] * S;
        if (sp <= maxv * maxv) {
            r = mid-1;
        } else {
            l = mid;
        }
    }
    int S = p[l]-s[i];
    int sp = v[i] * v[i] + 2 * a[i] * S;
    if (sp <= maxv*maxv) return -1;
    return l;
}

void getLR(int i) {
    if (a[i] < 0) {
        if (v[i] <= maxv) return;
        l[nn] = lower_bound(p, p+m, s[i])-p;
        r[nn++] = bs2(i);
        if (r[nn-1] == -1) {
            nn--; return;
        }
    } else if (a[i] == 0) {
        if (v[i] > maxv)
            l[nn] = lower_bound(p, p+m, s[i])-p,
            r[nn++] = m-1;
    } else {
        l[nn] = bs(i);
        if (l[nn] == -1) return;
        r[nn++] = m-1;
    }
    if (l[nn-1] > r[nn-1]) nn--;
}

void solve() {
    int L;
    scanf("%d%d%d%d",&n,&m,&L,&maxv);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d",&s[i],&v[i],&a[i]);
    }
    for (int i = 0; i < m; i++) {
        scanf("%d",&p[i]);
    }

    nn=0;
    for (int i = 0; i < n; i++) getLR(i);
    
    printf("%d ",nn);

    int ans = 0;
    for (int i = 0; i < nn; i++) pa[i] = pair<int, int>{l[i], r[i]};
    sort(pa,pa+nn);
    for (int i = 0; i < nn; i++) {
        int cur = 1, r = pa[i].second;
        for (int j = i; j < nn; j++) {
            while (j < nn && pa[j].first <= r) j++;
            r = pa[j].second;
            if (j != nn) cur++;
        }
        ans = max(ans, cur);
    }
    printf("%d\n",m-ans);
}

signed main() {
    freopen(NAME ".in", "r", stdin);
    freopen(NAME ".out", "w", stdout);

    //initFact();

    int t; scanf("%d", &t);
    while (t--) {
        solve();
    }

    return 0;
}